<script type="text/javascript">
    $(document).ready(function() {
        $('.ui .item').on('click', function() {
            $('.ui .item').removeClass('active');
            $(this).addClass('active');
        });
        $('.ui.dropdown').dropdown({
            on: 'hover'
        });
        $('.ui.checkbox').checkbox();
    });

    $(document).ready(function() {
        $( "td.seat" ).on( "click", function() {
            var img = $(this).find('img');
            var row = img.attr("data-row");
            var column = img.attr("data-col");
            var ticket_id = $('input[name="hidd_temp_ticket_id"]').val();
                $.ajax({
                    type: "POST",
                    url: "<?php echo LINK_ROOT . DIR_AJAX; ?>seat_selection.php",
                    data: "ticket_id=" + ticket_id
                            + "&row=" + row
                            + "&column=" + column
                            + "&book_quantity=" + book_quantity
                            + "&booking_id=" + booking_id,
                    success: function (data) {
                        var data_json = jQuery.parseJSON( data );
                        if (data_json.success) {
                            if (data_json.changed) {
                                img.attr("src", data_json.next_seat_info.image_url);
                                book_quantity = data_json.book_quantity;
                            } else {
                                alert(data_json.notify);
                            }
                        } else {
                            alert(data_json.notify);
                        }
                    }
                });
        });
    });

    function submitRegister() {
        $("#form_register").submit();
    }

    function submitLogin() {
        $("#form_login").submit();
    }

    function navigate(url) {
        window.location = url;
    }
    
    function submit_book_data() {
        $("#form_book_ticket").submit();
    }
    
    function submit_choose_combo() {
        $("#form_choose_combo").submit();
    }
</script>